package com.ssm.helong.shop.controller;

import com.ssm.helong.shop.entity.Address;
import com.ssm.helong.shop.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/Address")
public class AddressController {
    @Autowired
    private AddressService addressService;

    @RequestMapping("selectAddress")
    public String selectAddress(Integer userId) {
        List <Address> addressList = addressService.selectAddress(userId);
        System.out.println(addressList);
        return "";
    }

    @RequestMapping("updateAddress")
    public String updateAddress(Address address) {
        int updateAddress = addressService.updateAddress(address);
        System.out.println(updateAddress);
        return "";
    }

    @RequestMapping("addAddress")
    public String addAddress(Address address) {
        int addAddress = addressService.addAddress(address);
        System.out.println(addAddress);
        return "";
    }

    @RequestMapping("deleteAddress")
    public String deleteAddress(Integer id) {
        int deleteAddress = addressService.deleteAddress(id);
        System.out.println(deleteAddress);
        return "";
    }

    @RequestMapping("selectOneAddress")
    public String  selectOneAddress(Integer id){
        addressService.selectOneAddress(id);
        return "";
    }
}
